/*
 * @Author: wurangkun
 * @Date: 2024-01-25 11:28:09
 * @LastEditTime: 2024-01-29 15:44:17
 * @LastEditors: wurangkun
 * @FilePath: \vue-template\composables\user.ts
 * @Description: 
 */
export const useUserInfo = defineStore("userInfo", {
  state: () => {
    const theDefault: UserKey = {
      token: "",
      userName: "",
      mobile: "",
    }
    const cookie = useLocalStorage<UserKey>('cookie', theDefault)
    const userInfo = ref<UserInfo | undefined>({
      userName: "wurangkun",
      mobile: ''
    })
    return { userInfo, cookie }
  },
  hydrate(storeState, initialState) {
    storeState.cookie = useLocalStorage<UserKey>('cookie', initialState.cookie).value
  }
})


if (import.meta.hot)
  import.meta.hot.accept(acceptHMRUpdate(useUserInfo, import.meta.hot))